package com.example.riseofthedefender;

import java.nio.FloatBuffer;

import javax.microedition.khronos.opengles.GL10;

import android.graphics.PointF;

public class Square {

	protected static FloatBuffer vertexBuffer;
	protected static float vertices[] = 
	{ 
			-1.0f, -1.0f, 0.0f,
			-1.0f, 1.0f, 0.0f,
			1.0f, -1.0f, 0.0f,
			1.0f, 1.0f, 0.0f
	};
	protected static FloatBuffer textureBuffer;
	protected static float texture[] = 
	{
			0.0f, 1.0f,
			0.0f, 0.0f,
			1.0f, 1.0f,
			1.0f, 0.0f
	};

	public static int IDSquare = 0;
	public int id = 0;
	public PointF pos = new PointF();
	public float wHlv = 0;
	public float hHlv = 0;
	public float xV = 0;
	public float yV = 0;
	public float rotateD = 0;
	
	protected float scaleX = 1f;
	protected float scaleY = 1f;
	
	public Square() 
	{
		wHlv = 20;
		hHlv = 20;
	}
	
	public void setScale(float x, float y)
	{
		scaleX = x;
		scaleY = y;
	}
	
	public void setPosition(float x, float y)
	{
		this.pos.x=x;
		this.pos.y=y;
	}
	
	public void setRotation(float rotate)
	{
		this.rotateD=rotate;
	}

	public void update()
	{
		pos.x+=3;
		if(pos.x>GameVar.cWidth)
			pos.x-=GameVar.cWidth;
	}
	
	public boolean collideWith(Square square)
	{
		return false;
	}
	
	public void draw(GL10 gl) 
	{
		gl.glLoadIdentity();
		gl.glTranslatef(pos.x+wHlv, pos.y+hHlv, 0.0f);
		gl.glBindTexture(GL10.GL_TEXTURE_2D, TextureManager.WITCH.textures[0]);
		gl.glScalef(wHlv, hHlv, 1.0f);
		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 3);
	}
}
